package com.wlyuan.open.controller;

import com.wlyuan.open.assembler.WaybillAssembler;
import com.wlyuan.open.order.dto.OpenOrderCombineDTO;
import com.wlyuan.transport.api.ICombineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import lombok.var;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "运单")
@Validated
@RequestMapping("/api")
@RestController
@Slf4j
public class OpenWaybillController {

    @DubboReference(check = false)
    private ICombineService combineService;

    @ApiOperation("拼车")
    @PostMapping("/order/combine")
    public void combine(@RequestBody OpenOrderCombineDTO combine) {
        var orderCombine = WaybillAssembler.assemble(combine);
        combineService.create(orderCombine);
    }

}
